import * as Router from 'koa-router';
import service from "./../service/_service";
let router = new Router();
router.prefix('/api')


/**
 * 新增工会
 */
router.post('/wechat/createUnion', async (ctx: any, next: any) => {
    let res = ctx.request.body;
    let result: any = await service.createUnion(res);
    ctx.status = 200;
    ctx.body = result;
    await next()
})

/**
 * 获取工会列表
 */
router.get('/wechat/getUnionList', async (ctx: any, next: any) => {
    let result: any = await service.getUnionList();
    ctx.status = 200;
    ctx.body = result;
    await next()
})

/**
 * 根据工会主键 查询简介
 */
router.post('/wechat/getIntroduceById', async (ctx: any, next: any) => {
    let res = ctx.request.body;
    let result: any = await service.getIntroduceById(res);
    ctx.status = 200;
    ctx.body = result;
    await next()
})

/**
 * 根据工会主键新增活动，默认为当前活动
 */
router.post('/wechat/createActivityById', async (ctx: any, next: any) => {
    let res = ctx.request.body;
    let result: any = await service.createActivityById(res);
    ctx.status = 200;
    ctx.body = result;
    await next()
})

/**
 * 根据工会主键查询 活动 isHistory 
 */
router.post('/wechat/getActivityById', async (ctx: any, next: any) => {
    let res = ctx.request.body;
    let result: any = await service.getActivityById(res);
    ctx.status = 200;
    ctx.body = result;
    await next()
})

/**
 * 根据工会主键 修改 简介
 */
router.post('/wechat/updateIntroduce', async (ctx: any, next: any) => {
    let res = ctx.request.body;
    let result: any = await service.updateIntroduce(res);
    ctx.status = 200;
    ctx.body = result;
    await next()
})


//这个是临时书写的为了方便添加数据用的 ，以后不会用到
router.get('/wechat/testCreate', async (ctx: any, next: any) => {
    let result: any = await service.testCreate();
    ctx.status = 200;
    ctx.body = result;
    await next()
})



export default router;